package com.hdu;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.URL;

/**
 * describe:
 *
 * @author wfd
 * @date 2019/08/27
 */
public class WyySinger {

    public static void main(String[] args) throws IOException {
        String url = "https://yinghua.ee/so.html?wd=" + "全职法师";
        getData(url);
    }

    public static void getData(String url) throws IOException {

        Document doc = Jsoup.parse(new URL(url), 20000);

        Elements cartoon = doc.select(".stui-vodlist__media li");
        Integer total = cartoon.size();


        for (Element element : cartoon) {
            System.out.println(element.getElementsByTag("a").attr("href"));
            System.out.println(element.getElementsByTag("a").attr("title"));
            System.out.println(element.getElementsByTag("a").attr("data-original"));
            System.out.println(element.getElementsByClass("pic-text").text());
            System.out.println();
        }
        Elements list = doc.select(".stui-page li");

        if (list.size() != 0) {
            String str = list.last().getElementsByTag("a").attr("href");
            total = Integer.parseInt(str.substring(str.lastIndexOf("/") + 1, str.lastIndexOf(".")));
        }
        System.out.println(total);
    }

}

